function fn(a, b, c) {
    return a + b + c;
}

//定长
const curry = function (fn, ...args) {
    if (args.length >= fn.length) {
        return fn(...args);
    } else {
        return function (...restArgs) {
            return curry(fn, ...args, ...restArgs);
        };
    }
};

const add = curry(fn);
console.log(add(1)(2)(3));
console.log(add(1, 2)(3));
